package com.cicoding.excption;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author:chandfy
 * @Description:
 * @Date:2022/7/21
 */
@ControllerAdvice
public class ExceptionHandle {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public String handle(Exception e){
        if(e instanceof BizException){
          BizException bizException = (BizException) e;
            System.out.println("[业务异常]{}"+e);
            return bizException.getMsg();
        }else{
            System.out.println("[系统异常]{}"+e);
            return ("系统异常"+e);
        }

    }

}
